<template>
  <div id="app">
    <TUIKit />
    <TUICallKit class="callkit-container" :allowedMinimized="true" :allowedFullScreen="false" />
  </div>
</template>
<script lang="ts">
import { TUIKit } from '../../TUIKit'
import { TUICallKit } from '@tencentcloud/call-uikit-vue2.6'
import storage from 'store'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { TUILogin } from '@tencentcloud/tui-core'
import { framework } from '@/TUIKit/adapter-vue'
import { genTestUserSig } from '@/TUIKit'
export default {
  components: {
    TUIKit,
    TUICallKit
  },
  mounted() {
    console.log('测试答应', this.$store.getters.nickname)
    console.log('测试答应', this.$store.getters.nickname)
    if (storage.get(ACCESS_TOKEN)) {
      // console.log('登录', storage.get('isReady'))

      // TUILogin.logout()

      storage.set('isReady', false)

      if (!storage.get('isReady') && this.$store.getters.nickname) {
        // TUILogin.logout()
        const userSig = genTestUserSig({
          SDKAppID: 1600084628,
          secretKey: 'be7e8cc168feb00b6c562b4ef8c46ccfea630bd3325d8cad87e351ddd778a165',
          userID: this.$store.getters.nickname
        })
        TUILogin.login({
          SDKAppID: 1600084628,
          userID: this.$store.getters.nickname,
          userSig: userSig.userSig,
          useUploadPlugin: true,
          framework
        })
          .then((res) => {
            console.log('登录成功', res.data.errorInfo === 'success')
            if (res.data.errorInfo === 'success') {
              storage.set('isReady', true)
            }
          })
          .catch((error) => {
            console.log('登录失败', error)
            storage.set('isReady', false)
            // reject(error)
          })
      }
    }
  }
}
</script>
<style lang="scss">
// #app {
//   padding: 20px;
// }
</style>
